home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Pascal / Games / Showwit! 1.0 / source code / Source / CShHelpDirector.p < prev    next >
Encoding:
Text File  |  1996-01-02  |  5.6 KB  |  229 lines  |  [TEXT/PJMM]

  1. {****************************************************}
  2. {}
  3. {        CShHelpDirector.p                                                                                                                                                                                        }
  4. {}
  5. {        DLOGDirector class for the director which handles the about/help dialog.                    }
  6. {}
  7. {****************************************************}
  8.  
  9.  
  10. unit CShHelpDirector;
  11.  
  12. interface
  13.  
  14.     uses
  15.         TCL, ShIntf;
  16.  
  17. implementation
  18.  
  19.     const
  20.         VuIDOKButton = 1;
  21.         VuIDPicture = 2;
  22.         VuIDAboutButton = 3;
  23.         VuIDHelpButton = 4;
  24.         VuIDCreditsButton = 5;
  25.  
  26.  
  27. {****************************************************}
  28. {}
  29. {        IShHelpDirector                                                                                                                                                                                                }
  30. {}
  31. {        Construction of the help director object.                                                                                                                     }
  32. {}
  33. {****************************************************}
  34.  
  35.     procedure CShHelpDirector.IShHelpDirector (aSupervisor: CShApp);
  36.  
  37.     begin { IShHelpDirector }
  38.         IDLOGDirector(DLOGAboutAndHelp, aSupervisor);
  39.  
  40.         itsPicture := CPicture(FindViewByID(VuIDPicture));
  41.         itsAboutButton := CButton(FindViewByID(VuIDAboutButton));
  42.         itsHelpButton := CButton(FindViewByID(VuIDHelpButton));
  43.         itsCreditsButton := CButton(FindViewByID(VuIDCreditsButton));
  44.     end; { IShHelpDirector }
  45.  
  46.  
  47. {****************************************************}
  48. {}
  49. {        Free                                                                                                                                                                                                                                }
  50. {}
  51. {     Destruction of the help director object. We set our pointers     to nil, for the             }
  52. {        objects to which they were pointing will be disposed of in inherited methods.        }
  53. {}
  54. {****************************************************}
  55.  
  56.     procedure CShHelpDirector.Free;
  57.  
  58.     begin { Free }
  59.         itsPicture := nil;
  60.         itsAboutButton := nil;
  61.         itsHelpButton := nil;
  62.         itsCreditsButton := nil;
  63.  
  64.         inherited Free;
  65.     end; { Free }
  66.  
  67.  
  68. {****************************************************}
  69. {}
  70. {        DoCommand                                                                                                                                                                                                            }
  71. {}
  72. {     The help director is responsible for changing between help screens.                                    }
  73. {}
  74. {****************************************************}
  75.  
  76.     procedure CShHelpDirector.DoCommand (theCommand: longint);
  77.  
  78.     begin { DoCommand }
  79.         case theCommand of
  80.  
  81.             cmdAboutScreen:  begin
  82.                 SetDialogPanes(AboutScreen);
  83.             end; { cmdAboutScreen }
  84.  
  85.             cmdHelpScreen:  begin
  86.                 SetDialogPanes(HelpScreen);
  87.             end; { cmdHelpScreen }
  88.  
  89.             cmdCreditsScreen:  begin
  90.                 SetDialogPanes(CreditsScreen);
  91.             end; { cmdCreditsScreen }
  92.  
  93.             otherwise begin
  94.                 inherited DoCommand(theCommand);
  95.             end; { otherwise }
  96.         end; { case }
  97.     end; { DoCommand }
  98.  
  99.  
  100. {****************************************************}
  101. {}
  102. {        Dawdle                                                                                                                                                                                                                        }
  103. {}
  104. {     Continuous scrolling of the credits screen.                                                                                                                }
  105. {}
  106. {****************************************************}
  107.  
  108.     procedure CShHelpDirector.Dawdle (var maxSleep: longint);
  109.  
  110.         const
  111.             kScrollStep = 1;
  112.             kScrollDelay = 1;
  113.  
  114.         var
  115.             theExtentH, theExtentV: LongInt;
  116.             theSpanH, theSpanV: Integer;
  117.             thePos: LongPt;
  118.             oldTicks: LongInt;
  119.  
  120.     begin { Dawdle }
  121.         if not itsCreditsButton.IsActive then begin
  122.  
  123.             itsPicture.GetExtent(theExtentH, theExtentV);
  124.             itsPicture.GetFrameSpan(theSpanH, theSpanV);
  125.             itsPicture.GetPosition(thePos);
  126.  
  127.             if thePos.v < theExtentV - theSpanV then begin
  128.                 itsPicture.Scroll(0, kScrollStep, kRedraw);
  129.             end { if }
  130.             else begin
  131.                 SetLongPt(thePos, 0, 0);
  132.                 itsPicture.ScrollTo(thePos, kRedraw);
  133.             end; { else }
  134.  
  135.             oldTicks := TickCount;
  136.             while TickCount <= oldTicks + kScrollDelay do begin
  137.                     { Nothing }
  138.             end; { while }
  139.  
  140.             maxSleep := 0;
  141.         end; { if }
  142.     end; { Dawdle }
  143.  
  144.  
  145. {****************************************************}
  146. {}
  147. {        SetDialogPanes                                                                                                                                                                                                }
  148. {}
  149. {     Set up the panes for each of the possible screens.                                                                                        }
  150. {}
  151. {****************************************************}
  152.  
  153.     procedure CShHelpDirector.SetDialogPanes (aScreenType: HelpScreenType);
  154.  
  155.         var
  156.             theTopLeftCorner: LongPt;
  157.             theSpanH, theSpanV: Integer;
  158.  
  159.     begin { SetDialogPanes }
  160.         case aScreenType of
  161.  
  162.             AboutScreen:  begin
  163.                 itsAboutButton.Deactivate;
  164.                 itsHelpButton.Activate;
  165.                 itsCreditsButton.Activate;
  166.                 if gSystem.hasColorQD then begin
  167.                     itsPicture.UsePICT(PICTAboutColour);
  168.                 end { if }
  169.                 else begin
  170.                     itsPicture.UsePICT(PICTAboutBW);
  171.                 end; { else }
  172.                 SetLongPt(theTopLeftCorner, 0, 0);
  173.             end; { AboutScreen }
  174.  
  175.             HelpScreen:  begin
  176.                 itsAboutButton.Activate;
  177.                 itsHelpButton.Deactivate;
  178.                 itsCreditsButton.Activate;
  179.                 if gSystem.hasColorQD then begin
  180.                     itsPicture.UsePICT(PICTHelpColour);
  181.                 end { if }
  182.                 else begin
  183.                     itsPicture.UsePICT(PICTHelpBW);
  184.                 end; { else }
  185.                 SetLongPt(theTopLeftCorner, 0, 0);
  186.             end; { HelpScreen }
  187.  
  188.             CreditsScreen:  begin
  189.                 itsAboutButton.Activate;
  190.                 itsHelpButton.Activate;
  191.                 itsCreditsButton.Deactivate;
  192.                 if gSystem.hasColorQD then begin
  193.                     itsPicture.UsePICT(PICTCreditsColour);
  194.                 end { if }
  195.                 else begin
  196.                     itsPicture.UsePICT(PICTCreditsBW);
  197.                 end; { else }
  198.                 itsPicture.GetFrameSpan(theSpanH, theSpanV);
  199.                 SetLongPt(theTopLeftCorner, 0, theSpanV);
  200.             end; { CreditsScreen }
  201.  
  202.         end; { case }
  203.  
  204.         itsPicture.ScrollTo(theTopLeftCorner, kNoRedraw);
  205.         itsPicture.Refresh;
  206.     end; { SetDialogPanes }
  207.  
  208.  
  209. {****************************************************}
  210. {}
  211. {        DoAboutAndHelp                                                                                                                                                                                            }
  212. {}
  213. {        Enter the about/help dialog, starting from the given first screen.                                         }
  214. {}
  215. {****************************************************}
  216.  
  217.     procedure CShHelpDirector.DoAboutAndHelp (aFirstScreen: HelpScreenType);
  218.  
  219.         var
  220.             theDismissCmd: LongInt;
  221.  
  222.     begin { DoAboutAndHelp }
  223.         SetDialogPanes(aFirstScreen);
  224.         BeginDialog;
  225.         theDismissCmd := DoModalDialog(cmdOK);
  226.     end; { DoAboutAndHelp }
  227.  
  228.  
  229. end. { CShHelpDirector }